package com.dingwen.treasure.easyexcel.convert;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.dingwen.treasure.base.enums.LogicDeleteEnum;
import com.dingwen.treasure.base.util.EnumUtil;

import java.math.BigDecimal;

/**
 * 　BaseEnumConverter: TODO 有问题
 * 　@author dingwen
 * 　@date 2022/8/2
 */
public class LogicDeleteEnumConverter implements Converter<LogicDeleteEnum> {

    @Override
    public LogicDeleteEnum convertToJavaData(ReadConverterContext<?> context) {
        BigDecimal numberValue = context.getReadCellData().getNumberValue();
        return ObjectUtil.isEmpty(numberValue) ? null : EnumUtil.getEnumByCode(LogicDeleteEnum.class,Convert.toInt(numberValue));
    }
}
